package day10_io_code.com.itheima.d2_buffer_stream;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

public class Test4 {
    public static void main(String[] args) {
        try (
                BufferedReader br = new BufferedReader(new FileReader("d:\\demo\\a.txt"));
                BufferedWriter bw = new BufferedWriter(new FileWriter("d:\\demo\\b.txt"));
        ){
            ArrayList<String> data = new ArrayList<>();

            String line;
            while ((line = br.readLine()) != null){
                data.add(line);
            }
            System.out.println("data = " + data);

            Collections.sort(data);

            System.out.println("data = " + data);

            for (String ln : data) {
                bw.write( ln);
                bw.newLine();
            }
            System.out.println("数据复制完毕...");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
